package services

import (
	"errors"
	"log"
)

var ErrConnectionFailed = errors.New("连接失败")

type ErrorHandler struct {
	RetryCount    int
	RetryInterval int
}

func NewErrorHandler(retryCount, retryInterval int) *ErrorHandler {
	return &ErrorHandler{
		RetryCount:    retryCount,
		RetryInterval: retryInterval,
	}
}

func (eh *ErrorHandler) HandleError(err error) error {
	if errors.Is(err, ErrConnectionFailed) {
		log.Printf("连接失败错误: %v", err)
		return eh.retryConnection(err)
	}
	log.Printf("处理错误: %v", err)
	return errors.New("处理错误: " + err.Error())
}

func (eh *ErrorHandler) retryConnection(err error) error {
	// 实现重试逻辑
	return nil
}
